import time
def metric(fn):
    def compute_time(*args,**kwargs):
        start_time = time.time()
        fn()
        end_time = time.time()
        print('耗时：{:.4f}s'.format(end_time-start_time))
        return fn(*args,**kwargs)
    return compute_time

@metric
def ftest():
    for i in range(1000000):
        pass

ftest()
